// pages/rfid_binds/locs_search/locs_search.js
import Dialog from '../../../miniprogram_npm/@vant/weapp/dialog/dialog';
const mybehavior = require("../../../behaviors/requests")
Page({
  behaviors: [mybehavior],
  /**
   * 页面的初始数据
   */
  data: {
    locs_no: "",
    data: [],
    showPicker: false,
  },
  onSubmit() {
    let that = this;
    Dialog.confirm({
        title: "信息确认",
        message: "物料编号:" + this.data.locs_no,
      })
      .then(() => {
        that.post("https://logisticsengineering.gree.com/rfid_api/rfid_manage/query_location", {
          material_no: that.data.locs_no,
        }).then(res => {
          if (res.code == 20000) {
            const data = res.data;
            that.setData({
              data: data,
              locs_no: ""
            });
            wx.showToast({
              title: res.msg,
            })
          } else {
            wx.showToast({
              title: res.msg,
              icon: "error"
            })
          }
        }).catch((e) => {
          wx.showToast({
            title: e.msg,
            icon: "none"
          })
        })
      })
      .catch(() => {
        Toast.fail("取消操作!");
      });
  },
  onClear() {
    Dialog.confirm({
      title: "数据重置",
      message: "确认数据重置？",
    }).then(() => {
      this.material_order = "";
      this.value = null;
      this.quantity = 0;
      Toast.success("数据已清零");
    });
  },
  onConfirm(value) {
    this.value = value;
    this.showPicker = false;
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})